import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// 按需引入vant
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from '@vant/auto-import-resolver';

// vite + ts项目，使用__dirname 需要安装@types/node
// npm i @types/node -D
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      /*
        // vite + ts项目中， 还需要在tsconfig.json中配置baseUrl和paths
        // tsconfig.json
        {
          "compilerOptions": {
            "baseUrl": "./",
            "paths": {
              "@/*" : ["src/*"]
            }
          }
        }
      */
      "@": path.resolve(__dirname, 'src')
    }
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [VantResolver()],
    }),
    Components({
      resolvers: [VantResolver()],
    }),
  ],
})
